#include <iostream>

using namespace std;

int cal(long long A, long long L)
{
	int count = 0;

	if (A > L) return 0;

	while (A != 1)
	{
		count++;
		if (A % 2 == 1) A = A*3 + 1;
		else A = A/2;
		if (A > L) return count;
	}

	return count+1;
}

int main()
{
	long long A, L;
	int ntest = 0;

	while (cin >> A >> L)
	{
		if (A == -1 && L == -1) break;
		cout << "Case " << (++ntest) << ": A = " << A << ", limit = " << L << ", number of terms = " << cal(A, L) << endl;
	}
	return 0;
}
